/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-03-03
*/
package com.rzico.market.controller;

import com.rzico.base.BaseController;
import com.rzico.base.CommResult;
import com.rzico.market.model.BigScreenVo;
import com.rzico.market.service.BigScreenService;
import com.rzico.market.service.PhoneProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 葫芦派大屏接口
 *
 * @author Rzico Boot
 * @version 1.0
 * @date 2020-03-03
 */

@Api(description = "葫芦派大屏接口")
@RestController
@RequestMapping("/bigScreen")
public class BigScreenController extends BaseController {

    @Autowired
    private BigScreenService bigScreenService;

    /**
     * 展示基础信息
     *
     * @return
     */
    @ApiOperation("展示基础信息")
    @GetMapping("/showBasic")
    @ApiImplicitParams({@ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "String", paramType = "query") ,
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "String", paramType = "query")
    })
    public CommResult<Map<String, Object>> showBasic(String startTime, String endTime) {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("startTime", startTime);
        params.put("endTime", endTime);

        int userAddNum = bigScreenService.selectUserAddNum(params);
        int userVisitNum = bigScreenService.selectUserVisitNum(params);
        BigDecimal orderAverageAmount = bigScreenService.selectOrderAverageAmount(params);
        int orderNum = bigScreenService.selectOrderNum(params);
        BigDecimal orderAmount = bigScreenService.selectOrderAmount(params);
        int orderProductNum = bigScreenService.selectOrderProductNum(params);
        BigDecimal orderProductAverageNum = bigScreenService.selectOrderProductAverageNum(params);
        List<BigScreenVo> mostProductCategory = bigScreenService.selectMostProductCategory(params);
        int allUserNum = bigScreenService.selectAllUserNum(params);
        BigDecimal allOrderAmount = bigScreenService.selectAllOrderAmount(params);
        BigDecimal orderCouponAmount = bigScreenService.selectOrderCouponAmount(params);

        result.put("userAddNum", userAddNum);
        result.put("userVisitNum", userVisitNum);
        result.put("orderAverageAmount", orderAverageAmount);
        result.put("orderNum", orderNum);
        result.put("orderAmount", orderAmount);
        result.put("orderProductNum", orderProductNum);
        result.put("orderProductAverageNum", orderProductAverageNum);
        result.put("mostProductCategory", mostProductCategory);
        result.put("allUserNum", allUserNum);
        result.put("allOrderAmount", allOrderAmount);
        result.put("orderCouponAmount", orderCouponAmount);

        return CommResult.success(result);
    }

    /**
     * 展示商品信息
     *
     * @return
     */
    @ApiOperation("展示商品信息")
    @GetMapping("/showProductInfo")
    @ApiImplicitParams({@ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "String", paramType = "query") ,
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "String", paramType = "query")
    })
    public CommResult<Map<String, Object>> showProductInfo(String startTime, String endTime) {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("startTime", startTime);
        params.put("endTime", endTime);

        List<BigScreenVo> productInfo = bigScreenService.selectProductInfoList(params);
        result.put("productInfo", productInfo);
        return CommResult.success(result);
    }

    /**
     * 展示支付信息
     *
     * @return
     */
    @ApiOperation("展示支付信息")
    @GetMapping("/showPayInfo")
    @ApiImplicitParams({@ApiImplicitParam(name = "hourNum", value = "小时数", dataType = "String", paramType = "query")
    })
    public CommResult<Map<String, Object>> showPayInfo(String hourNum) {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("hourNum", hourNum);

        List<BigScreenVo> payInfo = bigScreenService.selectPayInfoList(params);
        result.put("payInfo", payInfo);
        return CommResult.success(result);
    }

}
